import React, { Component } from "react";
import PropTypes from "prop-types";
// components
import GroupHeader from "./groupHeader";
import TextForm from "../../components/TextForm/form.js";

// utils
import addWaterMark from "../../utils/addWaterMark.js";
import { openLink } from "../../utils/dingtalk.js";

const empStatusMapper = {
  "1": "待入职",
  "2": "试用",
  "3": "正式",
  "4": "已离职",
  "5": "待离职"
};
const empTypeMapper = {
  "1": "全职",
  "2": "兼职",
  "3": "实习",
  "4": "劳务派遣",
  "5": "退休返聘",
  "6": "劳务外包"
};

const mapper = {
  position: "职位",
  sex: "性别",
  department: "主部门",
  director: "部门主管",
  birthday: "生日",
  contractCompanyName: "合同公司",
  confrimJoinTime: "入职时间",
  contractTime: "合同起止时间",
  nickName: "花名",
  employeeType: "员工类型",
  employeeStatus: "员工状态",
  jobNumber: "工号",
  joinWorkingTime: "首次参加工作时间"
};
export default class Profile extends Component {
  constructor(props) {
    super(props);
  }

  componentDidMount() {
    addWaterMark();
  }

  render() {
    const userInfo = this.props.userInfo || {};
    const { isSelf } = this.props;
    const t = this;
    // 将员工状态和员工类型字段转化为 human readable
    userInfo.employeeType = empTypeMapper[userInfo.employeeType];
    userInfo.employeeStatus = empStatusMapper[userInfo.employeeStatus];
    const tipsName = "growth-tips";
    return (
      <div className="growth-profile waterMark" onClick={() =>{
          window._rlog(`_growth_to_profile`);
          //window.location.hash = `preview?isSelf=${isSelf}`
          // if(isSelf){
          //   window.location.hash = `hrcenter/preview?isSelf=${isSelf}`;
          // }else{
          //   window.location.hash = `preview?isSelf=${isSelf}`;
          // }
          openLink(`#/preview?isSelf=${isSelf}`)
        }}>
        {
          /**
           * desc={!userInfo.perfectFlag && userInfo.employeeStatus !== "已离职" &&  
            <ToolTips title="必填信息不完整，请补充" tipsName={tipsName} >
              <Icon className="dir-warning-icon" size="xxs" type={require('../../../assets/svg/warning.svg')} />
            </ToolTips>
          }
           */
        }
        <GroupHeader
          title="个人档案"
          color="blue"
          perfectFlag={userInfo.perfectFlag}
          icon={
            <img
              className="growth-profile-icon"
              src="https://gw.alicdn.com/tfs/TB1Fv8rcLBNTKJjy0FdXXcPpVXa-80-80.png"
            />
          }
          onClick={() => {}}
        />
        <div className="growth-profile-text-form">
          <TextForm data={userInfo} labelMapper={mapper} />
        </div>
      </div>
    );
  }
}

Profile.propTypes = {
  userInfo: PropTypes.object
};
